
 interface Buyer{
    public abstract float buy(Fruit fruit);
}

class StudentBuyer implements Buyer {

    public float buy(Fruit fruit) {
        return fruit.money();
    }
}



class Fruit {
    public String name;
    public float weight;
    public float price;

    public float money(){
        return weight * price;
    }
}




class Apple extends Fruit{
    public Apple() {
        super();
    }

    public Apple(String name,Float weight,Float price){
        this.name = name;
        this.weight = weight;
        this.price = price;
    }

}


class Banana extends Fruit{
    public Banana() {
        super();
    }

    public Banana(String name,Float weight,Float price){
        this.name = name;
        this.weight = weight;
        this.price = price;
    }
}






public class text {
    public static void main(String[] args) {
        Apple apple = new Apple("Apple",3.0f,1.0f);
        Banana banana = new Banana("Banana",2.0f,7.0f);
        StudentBuyer studentBuyer = new StudentBuyer();
        System.out.println( "香蕉的重量"+ banana.weight + "香蕉的价格" + studentBuyer.buy(banana));
        System.out.println("苹果的重量"+ apple.weight + "苹果的价格"+studentBuyer.buy(apple));

    }
}
